<?php
class form{
	public $method;
	public $action;
	public $upload;

	public function form($method='post',$action='',$upload=false){
		$this->method = $method;
		$this->action = $action;
		$this->upload = $upload;
		echo "<form method=\"{$this->method}\"";
		if($this->action != ""){
			echo " action=\"{$this->action}\"";
		}
		if($this->upload){
			echo " enctype=\"multipart/form-data\"";
		}
		echo ">\n";
	}

	public function end(){
		echo "</form>";
	}

	public function generate_text($name,$value){
		$field = "<input type=\"text\" name=\"{$name}\" value=\"{$value}\" />";
		return $field;
	}

	public function generate_yesno($name,$value){
		$field = "<label><input type=\"radio\" name=\"{$name}\" value=\"1\"".(($value==0)?" checked":"").">No</label> <label><input type=\"radio\" name=\"{$name}\" value=\"1\" ".(($value==1)?" checked":"")." />Yes</legend>";
		return $field;
	}

	public function generate_textarea($name,$value,$cols=25,$rows=10){
		$field = "<textarea cols=\"{$cols}\" rows=\"rows\">{$value}</textarea>";
		return $field;
	}
}
?>